package com.punai.customer.controller;

import com.punai.common.annotation.Log;
import com.punai.common.core.controller.BaseController;
import com.punai.common.core.domain.AjaxResult;
import com.punai.common.enums.BusinessType;
import com.punai.customer.domain.CusLinkSubpkConsumeAddress;
import com.punai.customer.domain.contants.CusConstants;
import com.punai.customer.service.ICusLinkSubpkConsumeAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * 标准费用项材机耗量地区Controller
 * 
 * @author zhx
 * @date 2023-02-02
 */
@RestController
@RequestMapping("/cus/linkSubpkConsumeAddress")
public class CusLinkSubpkConsumeAddressController extends BaseController
{
    @Autowired
    private ICusLinkSubpkConsumeAddressService cusLinkSubpkConsumeAddressService;

    /**
     * 获取标准费用项材机耗量地区详细信息
     */
    @PreAuthorize("@ss.hasPermi('cus:linkSubpkConsumeAddress:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(cusLinkSubpkConsumeAddressService.selectCusLinkSubpkConsumeAddressById(id));
    }

    /**
     * 新增标准费用项材机耗量地区
     */
    @PreAuthorize("@ss.hasPermi('cus:linkSubpkConsumeAddress:add')")
    @Log(title = CusConstants.GX_NAME + "材机耗量地区", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CusLinkSubpkConsumeAddress cusLinkSubpkConsumeAddress)
    {
        return toAjax(cusLinkSubpkConsumeAddressService.insertCusLinkSubpkConsumeAddress(cusLinkSubpkConsumeAddress));
    }

    /**
     * 修改标准费用项材机耗量地区
     */
    @PreAuthorize("@ss.hasPermi('cus:linkSubpkConsumeAddress:edit')")
    @Log(title = CusConstants.GX_NAME + "材机耗量地区", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CusLinkSubpkConsumeAddress cusLinkSubpkConsumeAddress)
    {
        return toAjax(cusLinkSubpkConsumeAddressService.updateCusLinkSubpkConsumeAddress(cusLinkSubpkConsumeAddress));
    }

    /**
     * 删除标准费用项材机耗量地区
     */
    @PreAuthorize("@ss.hasPermi('cus:linkSubpkConsumeAddress:remove')")
    @Log(title = CusConstants.GX_NAME + "材机耗量地区", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(cusLinkSubpkConsumeAddressService.deleteCusLinkSubpkConsumeAddressByIds(ids));
    }

    /**
     * 修改时间
     */
    @PutMapping("/updateTime/{id}")
    public AjaxResult updateTime(@PathVariable String id)
    {
        return toAjax(cusLinkSubpkConsumeAddressService.updateTime(id,getCompanyId()));
    }
}
